home *** CD-ROM | disk | FTP | other *** search
- <?php if (!defined("SOaccess")) { define("SOaccess", 1);
-
- include("SOhttp.php");
-
- // Retrieve Access table or query fields over specified row numbers.
- // Inputs:
- // $sAddr: address of BadBlue server (e.g., "127.0.0.1:8080")
- // $sPath: path of shared file in EXT.INI file (e.g., "path11")
- // $sFile: name of Access MDB file to examine (e.g., "mlb2000.mdb")
- // $sTable: name of table (or query) to retrieve
- // $aData: associative/indexed array that is returned with data
- // $nRowStart: numeric zero-based row to start retrieving
- // $nRows: number of rows to retrieve
- // $sUser: (optional) user-name to get access to file
- // $sPassword: (optional) password to get access to file
- // Outputs:
- // $errmsg: empty if no error occurred, otherwise error message
- //
- function SOAccess($sAddr, $sPath, $sFile, $sTable, &$aData,
- $nRowStart, $nRows, $sUser = "", $sPassword = "") {
- $aData = array();
- $errmsg = "";
- do {
-
- // Construct URL and grab page...
- //
- $sURL = "http://".$sAddr."/ext.dll?MfcISAPICommand=LoadPage&".
- "page=mdb.htx&a0=/get/".$sPath."/".rawurlencode(trim($sFile)).
- "&a1=".rawurlencode(trim($sTable))."&a2=V&a3=&a4=".
- $nRowStart."&a8=".$nRows."&a9=";
- $errmsg = SOHTTPGet($sURL, &$sPage, $sUser, $sPassword);
- if (strlen($errmsg)) {
- break;
- }
- $aColumns = array();
- // echo($sPage);
-
- // Rip through first row of matrix to grab column labels.
- //
- for ($i = 0; $i < 255; $i++) {
- $sTemp = "<td class=fXH align=center>";
- $nCursor = strpos($sPage, $sTemp);
- if ($nCursor === false) {
- break;
- }
- $nCursor += strlen($sTemp);
- $sColumn = substr($sPage, $nCursor, 255);
- if (($nCursor2 = strpos($sColumn, '<')) > 0) {
- $sColumn = substr($sColumn, 0, $nCursor2);
- }
- $aColumns[$i] = strtolower($sColumn);
- $sPage = substr($sPage, $nCursor + 2);
- }
- if (strlen($errmsg)) {
- break;
- }
- if (!sizeof($aColumns)) {
- $errmsg = "Invalid template file (1)";
- break;
- }
- // echo("Columns (".sizeof($aColumns).")=".implode(", ", $aColumns)."<BR>");
-
- // Rip through multiple rows of data...
- //
- for ($i = 0; $i < $nRows; $i++) {
- for ($j = 0; $j < sizeof($aColumns); $j++) {
- $sTemp = "<td class=fXL";
- $nCursor = strpos($sPage, $sTemp);
- if ($nCursor === false) {
- if (!$i) {
- $errmsg = "No more data found";
- }
- break;
- }
- $nCursor += strlen($sTemp);
- $nCursor = strpos($sPage, ">", $nCursor);
- if ($nCursor === false) {
- $errmsg = "Invalid template file (3)";
- break;
- }
- $nCursor++;
- //
- $sVal = substr($sPage, $nCursor, 255);
- if (($nCursor2 = strpos($sVal, '<')) > 0) {
- $sVal = substr($sVal, 0, $nCursor2);
- }
- //
- $sPage = substr($sPage, $nCursor + $nCursor2);
- $aData[$nY + $i][$aColumns[$j]] = $sVal;
- // echo("Val: ".($nY + $i).$aColumns[$j]."= ".$sVal."<BR>");
- }
- if (strlen($errmsg)) {
- break;
- }
- }
-
- } while (0);
- return ($errmsg);
- }
-
- } ?>
-